﻿using System;
using System.Collections.Generic;
using YJKArchUtils.Utils;

namespace YJKRevitDimensionText.OneKeyPlanDim.Utility
{
	public class CommonLengthLevelDimDataInfo
	{
		public CommonLengthLevelDimDataInfo(SingleLevelDimDataInfo singleLevelDimDataInfo)
		{
			this.m_lstSingleLevelDimDataInfo.Add(singleLevelDimDataInfo);
			this.m_dLadderLineLength = singleLevelDimDataInfo.LadderLineLength;
		}

		public double LadderLineLength
		{
			get
			{
				return this.m_dLadderLineLength;
			}
		}

		public List<CommonDirectionLevelDimDataInfo> SortlstCommonDirectionLevelDimDataInfo
		{
			get
			{
				return this.m_SortlstCommonDirectionLevelDimDataInfo;
			}
		}

		public bool IsEqualLadderLineLength(SingleLevelDimDataInfo singleLevelDimDataInfo)
		{
			return Geometry.IsEqual(this.m_dLadderLineLength, singleLevelDimDataInfo.LadderLineLength);
		}

		public void AddElement(SingleLevelDimDataInfo singleLevelDimDataInfo)
		{
			this.m_lstSingleLevelDimDataInfo.Add(singleLevelDimDataInfo);
		}

		public void SortOperator()
		{
			foreach (SingleLevelDimDataInfo singleLevelDimDataInfo in this.m_lstSingleLevelDimDataInfo)
			{
				bool flag = false;
				foreach (CommonDirectionLevelDimDataInfo commonDirectionLevelDimDataInfo in this.m_SortlstCommonDirectionLevelDimDataInfo)
				{
					if (commonDirectionLevelDimDataInfo.IsCommonDir(singleLevelDimDataInfo))
					{
						commonDirectionLevelDimDataInfo.AddElement(singleLevelDimDataInfo);
						flag = true;
						break;
					}
				}
				if (!flag)
				{
					CommonDirectionLevelDimDataInfo item = new CommonDirectionLevelDimDataInfo(singleLevelDimDataInfo);
					this.m_SortlstCommonDirectionLevelDimDataInfo.Add(item);
				}
			}
			foreach (CommonDirectionLevelDimDataInfo commonDirectionLevelDimDataInfo2 in this.m_SortlstCommonDirectionLevelDimDataInfo)
			{
				commonDirectionLevelDimDataInfo2.SortOperator();
			}
			this.m_SortlstCommonDirectionLevelDimDataInfo.Sort(new CommonDirectionLocationComparer());
		}

		private double m_dLadderLineLength;

		private List<SingleLevelDimDataInfo> m_lstSingleLevelDimDataInfo = new List<SingleLevelDimDataInfo>();

		private List<CommonDirectionLevelDimDataInfo> m_SortlstCommonDirectionLevelDimDataInfo = new List<CommonDirectionLevelDimDataInfo>();
	}
}
